<template>
  <div class="app-container clearfix">  
    <div class="filter-container">
      <el-form ref="filterForm" :model="filterForm" :inline="true" label-position="left" label-width="100px">
        <el-form-item label="客户ID" prop="clientID">
          <el-input v-model="filterForm.clientID" clearable placeholder="客户ID" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
        </el-form-item>
        <el-form-item label="手机号码" prop="telephone">
          <el-input v-model="filterForm.telephone" clearable placeholder="手机号码" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
        </el-form-item>
        <el-form-item label="渠道" prop="channelID">
          <el-input v-model="filterForm.channelID" clearable placeholder="渠道" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
        </el-form-item>
        <el-form-item label="代理" prop="agentID">
          <el-input v-model="filterForm.agentID" clearable placeholder="代理" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
        </el-form-item>
        <el-form-item label="销售代表" prop="employeeID">
          <el-input v-model="filterForm.employeeID" clearable placeholder="销售代表" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
        </el-form-item>
        <el-form-item label="区域" prop="districtID">
          <el-input v-model="filterForm.districtID" clearable placeholder="区域" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
        </el-form-item>
      </el-form>
      <el-button @click="handleFilter()">搜索</el-button>
    </div>
      <el-table
      :data="list"
      border
      style="width: 100%">
    <el-table-column
     label="编号"
      type="selection"
      width="50">
    </el-table-column>
      <el-table-column
        label="客户名称">
        <template slot-scope="{row}">
          <div>{{ row.mobile }}</div>
          <div>{{ row.clientCode }}</div>
        </template>
      </el-table-column>
      <el-table-column
        label="渠道" width="100">
        <template slot-scope="{row}">
          <span>{{ row.channel.channelName }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="注册区域" width="100">
        <template slot-scope="{row}">
          <span>{{ row.regionName }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="客户等级" width="100">
        <template slot-scope="{row}">
          <span>{{ row.grade.gradeName }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="代理" width="100">
        <template slot-scope="{row}">
          <span>{{ row.agent.fullname }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="注册时间" width="160">
        <template slot-scope="{row}">
          <span>{{ row.registerDate }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="最近登录" width="160">
        <template slot-scope="{row}">
          <span>{{ row.loginTime }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        width="400">
        <template slot-scope="{row}">
            <el-button @click="handleSubscribeRemove(row)" >冻结</el-button>
        </template>
      </el-table-column>
      </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="filterForm.page" :limit.sync="filterForm.size" @pagination="getList" />
  </div>
</template>

<script>
import waves from '@/directive/waves' // waves directive
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import {getSymbol} from '@/utils/symbol' // secondary package based on el-pagination
import {getClientList} from '@/api/customer/client'



export default {
  name: 'financeDashboard',
  components: { Pagination },
  directives: { waves },
  filters: {
  },
  data() {
    return {
      
      socket:"",
      tableKey: 0,
      list: null,
      windowHeight:"600",
      total: 0,
      listLoading: false,
      documentationList:[],
      connected:"loading",
      timer:null,
      filterForm: {
        page: 1,
        size: 10,
        localSymbol:"",
        status:5,
        style:"0",
        keyword: undefined
      }
    }
  },
  created() {
    let symbolData = getSymbol()
    try {
      this.filterForm.localSymbol = symbolData.code
    } catch (error) {
      
    }
    this.getList()
  },
  destroyed () {
      // 销毁监听
      this.close()
      clearInterval(this.timer)
      console.log("清除定时器")
  },
  methods: {
    getList:function(){
      let _this = this;
      console.log("期权",_this.filterForm)
      getClientList(_this.filterForm).then((response) => {
        console.log("getList",response)
          if (response.code === 200) {
            this.list = response.data.list
            this.total = response.data.total
          } else {
            _this.$message({
              message: response.msg,
              type: 'error'
            })
          }
      })
    },
    handleFilter() {
      this.filterForm.page = 1
      this.getList()
    },
    sortChange:function(){

    }
  }
}
</script>
<style>
.filter { float: left; width: 160px; padding: 20px; min-height: 600px; }
.article { float: left; width: 800px; }
.article-item { width: 800px; height: 200px; margin-right: 25px; }
.article-item-text { float: left; width:600px; }
.article-item-icon { float: right; width:200px; height:150px; padding-left: 50px; }
.article-item-icon img { width:100%; height:100%; border-radius: 10px; }
</style>